<template>
  <el-dialog title="发布优惠卷" :visible.sync="dialogVisible">
    <el-form
      :model="ruleForm"
      :rules="rules"
      ref="ruleForm"
      label-width="100px"
      class="demo-ruleForm"
    >
      <el-form-item label="优惠卷名称" prop="name">
        <el-input
          v-model="ruleForm.name"
          placeholder="请输入优惠卷名称"
        ></el-input>
      </el-form-item>
      <el-form-item label="发放数量" prop="name">
        <el-input
          v-model="ruleForm.name"
          placeholder="请输入发放数量"
        ></el-input>
      </el-form-item>
      <el-form-item label="有效期至" prop="name">
        <el-date-picker
          v-model="value1"
          type="date"
          style="width: 100%"
          placeholder="选择日期"
        >
        </el-date-picker>
      </el-form-item>
      <el-form-item label="消费积分" prop="name">
        <el-input
          v-model="ruleForm.name"
          placeholder="请输入消费积分"
        ></el-input>
      </el-form-item>
      <el-form-item label="抵扣金额" prop="name">
        <el-input
          v-model="ruleForm.name"
          placeholder="请输入抵扣金额"
        ></el-input>
      </el-form-item>
      <el-form-item label="最低可用金额" prop="name">
        <el-input
          v-model="ruleForm.name"
          placeholder="请输入最低可用金额"
        ></el-input>
      </el-form-item>
      <el-form-item label="备注" prop="name">
        <el-input
          type="textarea"
          :autosize="{ minRows: 3, maxRows: 3 }"
          placeholder="请输入内容"
          v-model="textarea2"
        >
        </el-input>
      </el-form-item>
    </el-form>

    <span slot="footer" class="dialog-footer">
      <el-button @click="dialogVisible = false">取 消</el-button>
      <el-button type="primary" @click="dialogVisible = false">确 定</el-button>
    </span>
  </el-dialog>
</template>

<script>
export default {
  data() {
    return {
      dialogVisible: false,
      ruleForm: {
        name: "",
        region: "",
        date1: "",
        date2: "",
        delivery: false,
        type: [],
        resource: "",
        desc: "",
      },
      rules: {
        name: [
          { required: true, message: "请输入活动名称", trigger: "blur" },
          { min: 3, max: 5, message: "长度在 3 到 5 个字符", trigger: "blur" },
        ],
        region: [
          { required: true, message: "请选择活动区域", trigger: "change" },
        ],
        date1: [
          {
            type: "date",
            required: true,
            message: "请选择日期",
            trigger: "change",
          },
        ],
        date2: [
          {
            type: "date",
            required: true,
            message: "请选择时间",
            trigger: "change",
          },
        ],
        type: [
          {
            type: "array",
            required: true,
            message: "请至少选择一个活动性质",
            trigger: "change",
          },
        ],
        resource: [
          { required: true, message: "请选择活动资源", trigger: "change" },
        ],
        desc: [{ required: true, message: "请填写活动形式", trigger: "blur" }],
      },
    };
  },
  methods: {
    open(item) {
      this.dialogVisible = true;
    },
    submitForm(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          alert("submit!");
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
    resetForm(formName) {
      this.$refs[formName].resetFields();
    },
  },
};
</script>

<style lang="less" scoped>
.box_field {
  border-color: rgba(190, 190, 190, 0.4);
  padding: 20px;

  .box_legend {
    padding: 0 8px;
    margin-left: 0.4rem;
    font-size: 16px;
  }
}

.detail_inle {
  font-size: 14px;
  color: black;

  & label {
    display: inline-block;
    text-align: right;
    width: 100px;
  }

  & :last-child {
    margin-left: 20px;
  }
}

.right {
  display: flex;
}

.center_text {
  display: flex;
  align-items: center;
}
</style>